<title>审核管理</title>
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb" lay-separator=">">
        <a lay-href=""><i class="layui-icon layui-icon-locate"></i>您当前的位置：</a>
        <a><cite>指标数据</cite></a>
        <a><cite>审核管理</cite></a>
    </div>
</div>
<div class="layui-fluid">
    <div class="manage-top">
        <div class="layui-card">
            <div class="layui-card-header">
                <div class="layui-header-title">
                    <i class="layui-icon audit-icon"></i>审核管理
                </div>
            </div>
            <div class="layui-card-body">
                <table id="auditManage-table" lay-filter="auditManage-table-filter"></table>
            </div>
        </div>
    </div>
    <div class="manage-bot">
        <div class="layui-row layui-col-space12">
            <div class="layui-col-md3 depart">
                <table id="custom-depart-table" lay-filter="depart-table-filter"></table>
            </div>
            <div class="layui-col-md9">
                <div class="layui-card">
                    <div class="layui-form" lay-filter="custom-indexdata-table">
                        <div class="layui-card-body">
                            <div class="layui-btn-container">
                                <button type="button" lay-submit class="layui-btn layui-btn-save" lay-filter="fill-data-submit">保存</button>
                                <button type="button" class="layui-btn layui-btn-pass T-btn" data-target="pass">
                                <i class="layui-icon layui-icon-ok"></i>通过
                                </button>
                                <button type="button" class="layui-btn layui-btn-return T-btn" data-target="return">
                                    <i class="layui-icon layui-icon-return"></i>退回
                                </button>
                                <button type="button" class="layui-btn layui-btn-score T-btn" data-target="score">查看得分</button>
                            </div>
                            <table id="my-custom-table" lay-filter="indicators-table"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .manage-top .layui-table{
        width: 100%;
    }
    .manage-top .layui-table thead tr td{
        padding: 8px 15px;
    }
    .layui-header-title{
        padding-left: 30px;
        position: relative;
    }
    .layui-card-header{
        height: 39px;
        line-height: 39px;
        border-bottom: 1px solid #D0D3DB;
    }
    .layui-card-header .audit-icon{
        width: 19px;
        height: 19px;
        background: url('/dist/style/res/param/auditManage/audit.png') no-repeat center center;
        background-size: cover;
        margin-top: -10px;
        left: 0px;
    }
    .layui-table-view .layui-table td, .layui-table-view .layui-table th{
        padding: 4px 0;
    }
    .manage-top .layui-table-cell{
		height: inherit;
	}
    .my-btn-audit, .my-btn-history, .my-btn-allDown, .layui-btn-downFile{
        width: 82px;
        height: 25px;
        line-height: 25px;
        padding: 0;
        background: transparent;
        border-radius: 4px;
    }
    .my-btn-audit{
        border: 1px solid #4BAA0B;
        color: #4BAA0B;
    }
    .my-btn-allDown, .layui-btn-downFile{
        border: 1px solid #5B80D6;
        color: #5B80D6;
    }
    .my-btn-history{
        border: 1px solid #5B80D6;
        color: #5B80D6;
    }
    .my-btn-audit:hover, .my-btn-allDown:hover, .layui-btn-downFile:hover{
        color: #F9C971;
        border-color: #F9C971;
    }
    .manage-top .layui-badge {
		height: 23px;
		line-height: 23px;
		border-radius: 10px;
        padding: 0 21px;
	}
    .layui-table tbody tr.lineactive {
        background-color: #FDE7A3 !important;
    }
    .layui-table[lay-even] tbody tr:nth-child(odd) {
        background-color: #D3E5FF;
    }
    .layui-table[lay-even] tbody tr:nth-child(even) {
        background-color: #fff;
    }
    .layui-table[lay-even] tbody tr:nth-child(odd):hover, .layui-table[lay-even] tbody tr:nth-child(even):hover{
        background-color: #f2f2f2; 
    }
    .manage-bot{
        margin-top: 13px;
    }
    .manage-bot .layui-card{
        height: 658px;
    }
    .manage-bot tr td{
        vertical-align: middle;
    }
    .layui-btn-save, .layui-btn-pass, .layui-btn-return, .layui-btn-download{
        width: 68px;
        height: 30px;
        line-height: 30px;
        color: #FFFFFF;
        padding: 0;
        background-color: #2669B1;
    }
    .layui-btn-download{
        width: 100px;
    }
    .layui-btn-save{
        padding-left: 20px;
        background: url('/start/TheForm/css/img/form-save.png') no-repeat 9px 7px #2669B1;
    }
    .layui-btn-score{
        width: 100px;
        height: 30px;
        line-height: 30px;
        color: #FFFFFF;
        padding-left: 32px;
        background: url('/dist/style/res/param/auditManage/defen.png') no-repeat 10px 8px #2669B1;
    }
    .my-btn-audit:hover, .my-btn-history:hover{
        color: orange;
        border-color: orange;
    }
    .my-custom-icon-folder{
        width: 22px;
        height: 16px;
        line-height: 16px;
        position: relative;
    }
    .my-custom-icon-folder::after{
        background-image: url('/dist/style/res/param/auditManage/icon-folder.png');
    }
    .ew-tree-table .my-custom-icon-folder:after {
        content: "";
        width: 20px;
        height: 18px;
        position: absolute;
        left: 0;
        top: -3px;
        background-size: cover;
        background-image: url('/dist/style/res/param/auditManage/icon-folder.png');
    }
    .layui-btn-record{
        height: 28px;
        line-height: 28px;
        background-color: #2669B1;
        margin-left: 10px;
    }
    .depart .layui-table-view {
        margin: 0;
    }
    .layui-btn-downFile, .my-btn-audit{
        width: 65px;
    }
    /* 下载附件的样式 */
    .dataFill-upload{  
        word-wrap: break-word;
        white-space: pre-wrap;
        word-break: break-all;
        max-width: 100%;
        height: auto;
        overflow: hidden;
        color: #23559D;
    }
    .upLoadSucessBox{
        position: absolute;
        left: 14%;
        top: 26px;
        background: #000;
        display: none; 
        z-index: 9999;
        color: #fff;
    } 
    .upLoadSucessBox>div{
        padding: 3px 6px;
    }
    .upLoadSucessBox>div>span:nth-child(1){
        cursor: pointer;
    }
    .upLoadSucessBox>div>span:nth-child(1):hover{
        color: #8ca8c7; 
        text-decoration: underline;
    }
</style>

<!-- 状态模板 -->
<script type="text/html" id="temporarystatusTpl">
	{{#
		var getStatusColor = function() {
			var mapColors = {
				'00': 'bgGreen',
				'20': 'layui-bg-blue',
				'25': 'layui-bg-orange',
				'30': 'layui-bg-orange',
				'40': 'layui-bg-cyan',
				'90': 'layui-bg-black',
				'99': 'layui-bg-black'
			};
			return mapColors[d.state] || '';
		};
	}}
	<span class="layui-badge {{getStatusColor()}}">{{d.statename}}</span>	
</script>

<!-- 附件模板 -->
<script type="text/html" id="temporaryenclosureTpl">
    {{#  if(!!d.fileMsg && d.fileMsg.length && d.fileMsg.length > 0){ 
        $.each(d.fileMsg, function(index, file) {
    }}
        <a class="T-btn" data-url="{{file.url}}" data-target="downFile" href="javascript:void(0);" lay-tips='{{file.filename}}'>{{file.filename}}</a>
    {{#  }) } else { }}
        
    {{#  } }}
</script>

<!-- 单位任务附件模板 -->
<script type="text/html" id="departTpl">
    {{#  if(!!d.fileList && d.fileList.length && d.fileList.length > 0){ 
        layui.each(d.fileList, function(index, file) {
    }}
        <a class="T-btn" lay-event="downFile" href="javascript:void(0);" lay-tips='{{file.filename}}'>{{file.filename}}</a>
    {{#  }) } else { }}
        
    {{#  } }}
</script>

<!-- 操作栏模板 -->
<script type="text/html" id="temporary-table-operate-bar">
    <button class="layui-btn my-btn-allDown" lay-event="allDown">批量下载</button>
</script>

<!-- 输入框模板 -->
<script type="text/html" id="datascore">
    {{# if(d.examine === 0){ }}
        <button type="button" class="layui-btn layui-btn-sm layui-btn-warn T-btn" data-target="examine" data-examine="{{d.examine_record}}"></button>
    {{# } }}
    <div class="layui-alg-select"></div>
    {{# if(!!d.write_value){ }}
        <input type="text" name="percent{{d.LAY_TABLE_INDEX}}" id="percent{{d.LAY_TABLE_INDEX}}" data-id="{{d.id}}" data-itemId="{{d.item_id}}" data-showVal="{{d.show_value}}" data-writeVal="{{d.write_value}}" class="layui-input my-input-style" value="{{d.write_value}}"/>
    {{# }else if(!!d.show_value){ }}
        <input type="text" name="percent{{d.LAY_TABLE_INDEX}}" id="percent{{d.LAY_TABLE_INDEX}}" data-id="{{d.id}}" data-itemId="{{d.item_id}}" data-showVal="{{d.show_value}}" data-writeVal="{{d.write_value}}" class="layui-input my-input-style" value="{{d.show_value}}"/>
    {{# }else if(!!d.datascore){ }}
        <input type="text" name="percent{{d.LAY_TABLE_INDEX}}" id="percent{{d.LAY_TABLE_INDEX}}" data-id="{{d.id}}" data-itemId="{{d.item_id}}" data-showVal="{{d.show_value}}" data-writeVal="{{d.write_value}}" class="layui-input my-input-style" value="{{d.datascore}}"/>
    {{# }else{ }}
        <input type="text" name="percent{{d.LAY_TABLE_INDEX}}" id="percent{{d.LAY_TABLE_INDEX}}" data-id="{{d.id}}" data-itemId="{{d.item_id}}" data-showVal="{{d.show_value}}" data-writeVal="{{d.write_value}}" class="layui-input my-input-style" value=""/>
    {{# } }}
    <span>请输入数值。</span>
</script>

<!-- 单位任务操作栏 -->
<script type="text/html" id="oplTpl">
    <button class="layui-btn my-btn-audit" lay-event="viewScore">查看得分</button>
</script>
<!-- 下载附件 --> 
<script type="text/html" id="fileUploadTem"> 
    <div class="dataFillfileBox">
        <a href="javascript:void(0)" id={{d.id}} class="dataFill-upload">下载附件</a>
        <div class="upLoadSucessBox"></div>
    </div>
</script>
<script>
    layui.use(['admin', 'table', 'tools', 'form', 'view', 'tableMerge'], function(){
        var admin = layui.admin,
            table = layui.table,
            tools = layui.tools,
            form = layui.form,
            view = layui.view,
            tableMerge = layui.tableMerge;
        
        var taskId = '',
            deptId = '',
            zbType = '',
            layout = ['.layui-table th', '.layui-table td'];

        form.render(null, 'custom-indexdata-table');
        initauditTable(); //加载审核任务表格
        
        function initauditTable(){
            admin.req({
                url: 'myapi/DC/api/rest/web/custom/GetIndexAuditTask',
                done: function(res){
                    if(res.data.retcode == 0){
                        var data = res.data.data;
                        table.render({
                            elem: '#auditManage-table',
                            height: 105,
                            even: true,
                            text: {
                                none: '<div class="no-data-tips"><img src="/dist/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>'
                            },
                            data: data,
                            cols: [[
                                {
                                    field: 'taskname',
                                    title: '任务名称',
                                    align: 'center'
                                }, {
                                    field: 'state',
                                    title: '状态',
                                    align: 'center',
                                    templet: '#temporarystatusTpl'
                                }, {
                                    field: 'starttime',
                                    title: '开始时间',
                                    align: 'center',
                                    templet: function(d) {
                                        return d.starttime.substring(0, 10);
                                    }
                                }, {
                                    field: 'endtime',
                                    title: '结束时间',
                                    align: 'center',
                                    templet: function(d) {
                                        return d.endtime.substring(0, 10);
                                    }
                                }, {
                                    field: 'fileMsg',
                                    title: '附件名称',
                                    align: 'center',
                                    templet: '#temporaryenclosureTpl'
                                },{
                                    field: 'memo',
                                    title: '说明',
                                    align: 'center'
                                },
                                {
                                    title: '操作',
                                    align: 'center',
                                    toolbar: '#temporary-table-operate-bar'
                                }
                            ]],
                            done: function(res, curr, count){
                                if(res.data && res.count > 0){
                                    var data = res.data;
                                    taskId = data[0].id;
                                    zbType = data[0].zbtype;
                                    $('[lay-id="auditManage-table"]').find('tbody tr').eq(0).addClass('lineactive');
                                    initDepartTable(taskId, zbType);
                                }
                                tools.setFont(layout);
                            }
                        })
                    }
                }
            })
        }

        /* 加载单位任务表格
        *@param taskid 任务id
        */
        function initDepartTable(taskid, zbtype){
             var zbtype = zbtype || '';
            admin.req({
                url: 'myapi/DC/api/rest/web/custom/DCGetTaskDepeTable',
                data: {
                    taskid: taskid
                },
                done: function(res){
                    var result = res.data;
                    if(result.retcode == 0){
                        table.render({
                            elem: '#custom-depart-table',
                            height: 658,
                            text: {
                                none: '<div class="no-data-tips"><img src="/dist/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>'
                            },
                            limit: 10000,
                            data: result.data,
                            cols: [[
                                { field: 'dept_name', title: '单位名称', align: 'center', 
                                    templet: function(d){
                                        return '<span lay-tips='+d.dept_name+'>'+d.dept_name+'</span>'
                                    }
                                },
                                { field: 'filename', title: '附件名称', toolbar: '#departTpl', align: 'center' }
                            ]],
                            done: function(res, curr, count){
                                if(res.data && res.count > 0){
                                    deptId = res.data[0].dept_id;  
                                    switch(zbtype){
                                        case '1':
                                            // $('[lay-id="custom-depart-table"]').find('tbody tr').eq(0).removeClass('lineactive');
                                            $('[lay-id="custom-depart-table"]').find('tbody tr').eq(0).addClass('lineactive');
                                            initTable(taskId,deptId);
                                            break;
                                        case '2':
                                            $('[lay-id="custom-depart-table"]').find('tbody tr').eq(0).addClass('lineactive');
                                            initTable(taskId, deptId);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }
                        })
                    }
                }
            })
        }

       //鼠标移入事件
       $("body").delegate(".dataFillfileBox","mouseover",function(){
                $(this).find(".upLoadSucessBox").show();  
        })
        $("body").delegate(".dataFillfileBox","mouseout",function(){
            $(this).find(".upLoadSucessBox").hide();  
        })  
        //下载文件
        $("body").delegate(".DataFilldownLoadFile","click",function(){//下载  
            var downLoadParam={  
                servername:$(this).parent().attr("servername"),
                filename:$(this).parent().attr("filename"),
                access_token: layui.data('layuiAdmin').access_token
            }  
            tools.downLoadfunction("myapi/DC/api/rest/web/custom/IndexFileDownloadAPI",downLoadParam,"下载文件");
        }) 
        //下载多文件 
        $("body").delegate(".dataFill-upload","click",function(e){//下载 
            e.stopPropagation();
            e.preventDefault();
            var downloadp={
                datascore_id:$(this).siblings().children().eq(0).attr("datasourceid"), 
                access_token: layui.data('layuiAdmin').access_token
            }     
            tools.downLoadMutipleDataFun("myapi/DC/api/rest/web/custom/IndexFilePackDownloadAPI",downloadp);
        })
        /* 加载指标数据表格
        *@param taskid 任务id
        */
        function initTable(taskid, deptid){ 
            admin.req({
                url: 'myapi/DC/api/rest/web/custom/GetIndexTaskAuditData',
                data: {
                    taskid: taskid,
                    dept_id: deptid
                },
                done: function(res){
                    if(res.data.retcode == 0){
                        var head = res.data.data.head,
                            data = res.data.data.data,
                            leafs = res.data.data.alg_leafs,
                            fileMap=res.data.data.fileMap,
                            toolCols = [
                                {field: 'datascore', templet: '#datascore', align: 'left', width: 200},
                                {type: 'checkbox', toolbar: '#recorde', align: 'center', width: 200},
                                {field: '', templet: '#fileUploadTem', align: 'center', width: 300}
                            ];
                        for(var i = 0; i < head.length; i++){
                            if(i == 0){
                                head[i].merge = true;
                            }else{
                                head[i].merge = [head[i-1].field, head[i].field];
                            }
                            head[i].minWidth = 200;
                            head[i].align = 'center';
                            (function(i){ 
                                head[i].templet = function(d){
                                    var field = d[head[i].field];
                                    if(field != 'datascore'){
                                        return '<span lay-tips='+field+'>'+field+'</span>'
                                    }
                                };
                            })(i);
                        }
                        head = head.concat(toolCols);
                        table.render({
                            elem: '#my-custom-table',
                            height: 586,
                            text: {
                                none: '<div class="no-data-tips"><img src="/dist/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>'
                            },
                            limit: 10000,
                            data: data,
                            cols: [head],
                            done: function(res, curr, count){
                                if(res.data && res.data.length > 0){
                                    tableMerge.render(this);
                                    var allTrs = $('[lay-id="my-custom-table"] tbody tr');
                                    $.each(allTrs, function(index, item){
                                        var btnNode = '<button type="button" class="layui-btn layui-btn-record T-btn" data-target="record" data-id='+res.data[index].id+'>查看记录</button>';
                                        // $(this).find('td:last-of-type .layui-table-cell').append(btnNode);
                                        $(this).find('.laytable-cell-checkbox').append(btnNode);
                                    })
                                    if(JSON.stringify(fileMap)!='{}'){ 
                                            //循环文件对象
                                            var newFileDataArr=[]; 
                                            for(var fileKey in fileMap){
                                                var newObj={};
                                                newObj.trId=fileKey; 
                                                newObj.fileData=fileMap[fileKey];
                                                newFileDataArr.push(newObj);
                                            }  
                                            for(var i=0;i<data.length;i++){
                                                for(var j=0;j<newFileDataArr.length;j++){
                                                    if(newFileDataArr[j].trId==data[i].id){ 
                                                        var eachFileData=newFileDataArr[j].fileData;
                                                        for(var k=0;k<eachFileData.length;k++) {
                                                            var newEachFileItem='<div fileId='+eachFileData[k].id+' datasourceId='+newFileDataArr[j].trId+' filename='+eachFileData[k].filename+'  servername='+eachFileData[k].servername+' ><span  class="DataFilldownLoadFile">'+eachFileData[k].filename+'</span></div>';
                                                            $(".dataFillfileBox").eq(i).find(".upLoadSucessBox").append(newEachFileItem);
                                                            $(".dataFillfileBox").parent(".layui-table-cell").css({"overflow":"visible"}); 
                                                        }  
                                                    }
                                                }
                                            }
                                        }
                                    initAlgSelect(leafs);
                                }
                            }
                        })
                    }
                    tools.setFont(layout);
                }
            })
        }

        /*
        * 加载算法下拉框
        *@param leafs 下拉框的值
        */
        function initAlgSelect(leafs){
            var allScores = $('[lay-id="my-custom-table"] tbody tr td[data-field="datascore"]');
            for(var i in leafs){
                var leafId = leafs[i][0].item_id;
                layui.each(allScores, function(index, item){
                    var iptId = $(this).find('input').data('itemid'),
                        showValue = $(this).find('input').data('showval') || '',
                        writeValue = $(this).find('input').data('writeval') || '';
                    if(iptId == leafId){
                        var container = $(this).find('.layui-alg-select'),
                            html = "<select class='myAlgSelect' lay-ignore>";
                        layui.each(leafs[i], function(i,each){
                            var newVal;
                            if(each.formula.indexOf("<")>0){
                                newVal = each.formula.replace('<', '< ');
                            }else{
                                newVal = each.formula;
                            }
                            if(each.formula == showValue){ 
                                html += "<option value='"+each.formula+"' data-writeVal='"+(writeValue ? writeValue : '')+"' data-type='"+each.item_value_type+"' data-id="+each.id+" selected>"+newVal+"</option>";
                            }else{
                                html += "<option value='"+each.formula+"' data-writeVal='"+(writeValue ? writeValue : '')+"' data-type='"+each.item_value_type+"' data-id="+each.id+">"+newVal+"</option>";
                            }
                        })
                        html += "</select>";
                        container.html(html);
                    }
                })
            }
            initAlgInput(); 
        }

        //为算法或值时显示隐藏输入框
        function initAlgInput(){
            var allSelects = $('.myAlgSelect');
            layui.each(allSelects, function(index, item){
                var selType = $(this).find('option:selected').data('type'),
                    iptVal = $(this).find('option:selected').data('writeval');
                $(this).parent().siblings('input').removeAttr('name');
                if(selType == '1'){
                     $(this).parent().siblings().not('button').removeClass('show').addClass('hidden');
                }else{
                    $(this).parent().siblings('input').val(iptVal).removeClass('hidden').addClass('show');
                    $(this).parent().siblings('span').removeClass('show').addClass('hidden');
                }
            })
        }

        //监听任务表格行单双击事件
		table.on('row(auditManage-table-filter)', function(obj){
            var data = obj.data;
			$('[lay-id="auditManage-table"]').find(obj.tr.selector).addClass('lineactive');
			$('[lay-id="auditManage-table"]').find(obj.tr.selector).siblings().removeClass('lineactive');
            taskId = data.id;
            zbType = data.zbtype;
            initDepartTable(taskId, zbType);
        })

        //监听单位任务表格行点击事件
        table.on('row(depart-table-filter)', function(obj){
            var data = obj.data;
			$('[lay-id="custom-depart-table"]').find(obj.tr.selector).addClass('lineactive');
			$('[lay-id="custom-depart-table"]').find(obj.tr.selector).siblings().removeClass('lineactive');
            deptId = data.dept_id;
            initTable(taskId, deptId);
        })

        //监听任务表格工具栏
        table.on('tool(auditManage-table-filter)', function(obj){
            var event = obj.event,
                data = obj.data;
            switch(event){
                case 'allDown':
                    if(data.id){
                        location.href = 'myapi/DC/api/rest/web/custom/IndexTaskFilePackDownload?taskid='+(data.id)+'&access_token='+layui.data('layuiAdmin').access_token
                    }else {
                        layer.msg('暂无下载附件的任务', {time: 1500});
                    }
                break;
                default: 
                break;
            }
        })

        //监听单位任务表格工具栏
        table.on('tool(depart-table-filter)', function(obj){
            var event = obj.event,
                data = obj.data;
            switch(event){
                case 'downFile':
                    location.href = 'myapi/DC/api/rest/web/custom/IndexTaskFilePackDownload?taskid='+taskId+'&deptid='+data.dept_id+'&access_token='+layui.data('layuiAdmin').access_token
                break;
                default: 
                break;
            }
        })
        

        //监听submit提交
        form.on('submit(fill-data-submit)', function(data){
            delete data.field['app'];
            delete data.field['layTableCheckbox'];
            delete data.field['file'];
            var field = data.field,
                val = [],
                fillData = [],
                allSelects = $('.myAlgSelect');
            for(var i in field){
                if($.trim(field[i])){
                    var reg  = new RegExp(/^\d+(?=\.{0,1}\d+$|$)/);
                    if(!reg.test(field[i])){
                        $('#'+i).focus();
                        layer.msg('请输入数字');
                        return ;
                    }
                    val.push(i);
                }
            }
            if(allSelects){
                layui.each(allSelects, function(index, item){
                    var selType = $(this).find('option:selected').data('type');
                    if(selType == '1'){ //值
                        var dataId = $(this).parent().siblings('input').data('id'),
                            selectId = $(this).find('option:selected').data('id'),
                            selectVal = $(this).find('option:selected').val();
                        fillData.push({ id: dataId, datascore: selectId, show_value: selectVal});
                    }else{ //2 为算法
                       var dataId = $(this).parent().siblings('input').data('id'),
                            selectId = $(this).find('option:selected').data('id'),
                            selectVal = $(this).find('option:selected').val(),
                            fillVal = $.trim($(this).parent().siblings('input').val());
                        fillData.push({ id: dataId, datascore: selectId, show_value: selectVal, write_value: fillVal });
                    }
                })
            }
            $.each(val, function(index, item){
                var id = $('#'+item).attr('data-id'),
                    datascore = $('#'+item).val();
                fillData.push({ id: id, datascore: datascore });
            })
            if(fillData && fillData.length > 0){
                admin.req({
                    url: 'myapi/DC/api/rest/web/custom/IndexTaskFillDataSave',
                    type: 'post',
                    data: {
                        data: JSON.stringify(fillData)
                    },
                    done: function(res){
                        if(res.data.retcode == 0){
                            initTable(taskId,deptId);
                            layer.msg(res.data.retmsg, {time: 1500});
                        }
                    }
                })
            }else {
                layer.msg('请填写数据之后再保存', {time: 1500});
            }
        })
        
        //点击事件
        $('.manage-bot').delegate('.T-btn', 'click', function(){
            var target = $(this).data('target');
            if(target == 'pass' || target == 'return'){
                    var checkStatus = table.checkStatus('my-custom-table'),
                        checkData = checkStatus.data,
                        memoTitle = '';
                    if(checkData && checkData.length > 0){
                        if(target == 'pass'){
                            memoTitle = '补充说明';
                        }else {
                            memoTitle = '退回原因';
                        }
                        layer.open({
                            id: 'usermemo',
                            type: 1,
                            title: '<i class="formFill-icon"></i><span style="color:#FFF;">'+memoTitle+'</span>',
                            area: ['300px', '290px'],
                            offset: 'auto',
                            shadeClose: true,
                            resize: false,
                            success: function(lay, index){
                                view(this.id).render('./audit/components/usermemo', {
                                    showReview: false,
                                    title: '审批意见'
                                });
                            },
                            btn: ['确定', '取消'],
                            btnAlign: 'c',
                            yes: function(index, layero){
                                $('.layui-btn-save').trigger('click');
                                var memoval = $('#usermemo .layui-textarea').val(),
                                    auditVal = [],
                                    model = target == 'pass' ? 'pass' : 'back';
                                layui.each(checkData, function(index, item){
                                    auditVal.push({ id: item.id, usermemo: memoval });
                                })
                                admin.req({
                                    url: 'myapi/DC/api/rest/web/custom/IndexTaskDataPassAndBack',
                                    type: 'post',
                                    data: {
                                        model: model,
                                        dept_id: deptId,
                                        data: JSON.stringify(auditVal)
                                    },
                                    done: function(res){
                                        if(res.data.retcode == 0){
                                            initTable(taskId, deptId);
                                            layer.msg(res.data.retmsg, {time: 1500});
                                        }
                                    }
                                });
                                layer.close(index);
                            },
                            btn2: function(index, layero){
                                layer.close(index);
                            }
                        })
                    }else {
                        layer.msg('请勾选需要提交审核的数据', {time: 1500});
                    }
            }else if(target == 'downFile'){
                var url = 'myapi/DC'+ $(this).data('url'),
                    name = $(this).text();
                tools.downMethodfunction(url, name);
            }else if(target == 'record'){
                var dataId = $(this).data('id');
                admin.req({
                    url: 'myapi/DC/api/rest/web/custom/GetIndexTaskOperatingData',
                    data: {
                        dataid: dataId
                    },
                    done:function(res){
                        var result = res.data;
                        if(result.retcode == 0){
                            if(result.data && result.data.length > 0){
                                layer.open({
                                    id: 'temporary-addhtml',
                                    title:'<i class="formFill-icon"></i><span style="color:#FFF;">查看记录</span>',
                                    offset: '110px',
                                    type: 1,
                                    shadeClose: true,
                                    area: ['350px', '400px'],
                                    resize: false,
                                    success: function(lay, index){
                                        view(this.id).render('./task/temporary/history', {history: result.data});
                                    }
                                })
                            }else{
                                layer.msg('暂无记录', {time: 1500});
                            }
                        }
                    }
                })
            }else if(target == 'allDown'){
                if(taskId){
                    location.href = 'myapi/DC/api/rest/web/custom/IndexTaskFilePackDownload?taskid='+taskId+'&access_token='+layui.data('layuiAdmin').access_token
                }else {
                    layer.msg('暂无下载附件的任务', {time: 1500});
                }
            }else if(target == 'eachDown'){
                if(taskId){
                    layer.open({
                        id: 'file-table',
                        title:'<i class="formFill-icon"></i><span style="color:#FFF;">分省下载</span>',
                        offset: '110px',
                        type: 1,
                        shadeClose: true,
                        area: ['500px', '450px'],
                        resize: false,
                        success: function(lay, index){
                            view(this.id).render('./param/component/fileList', {taskid: taskId});
                        }
                    })
                }else {
                    layer.msg('暂无下载附件的任务', {time: 1500});
                }
            }else if(target == 'score'){
                var departTasks = $('[lay-id="custom-depart-table"] tbody tr'),
                    flag = false,
                    param = { taskid: taskId, isAll: 'true' };
                layui.each(departTasks, function(index, item){
                    if($(this).hasClass('lineactive')){
                        flag = true;
                    }
                });
                if(flag){ param.deptid = deptId }
                if(zbType == '2' && !flag){
                    layer.msg('请选择单位任务', {time: 1500});
                    return ;
                }
                layer.open({
                    id: 'viewScoew-html',
                    title:'<i class="formFill-icon"></i><span style="color:#FFF;">查看得分</span>',
                    type: 1,
                    offset: '20px',
                    shadeClose: true,
                    area: ['1400px', '650px'],
                    resize: false,
                    success: function(lay, index){
                        view(this.id).render('./param/component/viewScore', param);
                    }
                })
            }else if(target == 'examine'){
                var recordHtml = $(this).data('examine').replace(/</g, '&lt;').replace(/>/g, '&gt;');
                layer.open({
                    id: 'examinePage',
                    title:'<i class="formFill-icon"></i><span style="color:#FFF;">格检详情</span>',
                    offset: '110px',
                    type: 1,
                    shadeClose: true,
                    area: ['400px', '300px'],
                    resize: false,
                    content: '<div class="layui-card-body">'+recordHtml+'</div>'
                })
            }
        })
    })
</script>